Inside Macintosh: QuickTime

Previous | Chapter Top | Chapter Contents | Next

Saving Movies in Movie Files

The Movie Toolbox allows you to save movies in movie files. Movie files have a file type of 'MooV' . Typically, the movie itself is stored in the resource fork of the movie file. The movie's data may reside in the data fork of the movie file, or in other files.

When you create a new movie, you must create a file to contain the movie data. Use the CreateMovieFile function (described on CreateMovieFile ) to create a new movie file. This function returns a file system reference number that you must use to identify the file to other Movie Toolbox functions. You can add your movie to the file by calling the AddMovieResource function (described on AddMovieResource ). When you are done with the file, you close it by calling the CloseMovieFile function (described on CloseMovieFile ). Your movie is now safely stored in the movie file.

If you are working with an existing movie, you must read that movie from a movie file or choose a movie from the scrap. You first open the movie file by calling the OpenMovieFile function (described on OpenMovieFile ). You then load the movie from that file by calling the NewMovieFromFile function (described on NewMovieFromFile ). Alternatively, you can use the NewMovieFromHandle function (described on NewMovieFromHandle ). After you have edited the movie, you must store it in your file if you want to save your changes. If you want to replace the old movie, use the UpdateMovieResource function (described on UpdateMovieResource ). If you want to keep the old movie, create a new movie by calling the AddMovieResource function described on AddMovieResource (a movie file may contain more than one movie resource). You should then close the movie file by calling the CloseMovieFile function (described on CloseMovieFile ).

The Movie Toolbox maintains a changed flag for each movie your application loads. You can use this flag to determine when to save your movie. The Movie Toolbox sets this flag to true whenever you make a change to a movie that should be saved. You can read this flag by calling the HasMovieChanged function (described on HasMovieChanged ). You can set the flag to false by calling the ClearMovieChanged function (described on ClearMovieChanged ).

The Movie Toolbox provides two functions for deleting movies: DeleteMovieFile and RemoveMovieResource . Use DeleteMovieFile (described on DeleteMovieFile ) to delete a movie file. Use RemoveMovieResource (described on RemoveMovieResource ) to delete a movie from a movie file. Don't use the corresponding standard Macintosh Toolbox routines ( FSpDelete and RmveResource ). The Movie Toolbox maintains movie references between files correctly whereas these routines do not.

The Movie Toolbox allows you to create movie files that contain all of their movie data, rather than containing references to data in other files. This may be necessary when creating a version of a movie that is to be moved to another computer system. The Movie Toolbox also accommodates operating systems that do not recognize files that contain more than one fork. In this case, you can use the FlattenMovie or FlattenMovieData functions (described on FlattenMovie and FlattenMovieData , respectively) to create a movie file that stores the movie and all of its data in the data fork of a Macintosh file. You can then transfer that file to another operating system. Your application may allow the user to decide how to save the movie. In this case, you can use a Save As dialog box similar to the one shown in Figure 32 . In this dialog box, the user can elect to create a movie file that contains all of the data for a movie by clicking the "Make movie self-contained" radio button.

Figure 32 A sample movie Save As dialog box


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next